close escape

Translations
едва удалось избежать
It was a close escape, but they managed to avoid the accident.
Это было едва удалось избежать, но они смогли избежать аварии.
Definitions
A situation in which someone narrowly avoids danger, harm, or an undesirable outcome; a near miss.